package qdu.rg05.test_uridata;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

public class Act1 extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ly_act1);
        //1. 事件源   2.对事件源对象调用侦听函数  3.创建侦听器对象，传给侦听函数
        View.OnClickListener mylistner = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent();
                switch(v.getId()){
                    case R.id.btn_sw1:
                        //  协议：//主机名（主路径） ：端口 /子路径? key=value
                        //Intent it = new Intent("myaction", Uri.parse("mysch://myqdu:8889"));
                        it.setAction("myaction");
                        it.setData(Uri.parse("mysch://myqdu:8889"));
                        startActivity(it);
                        break;
                    case R.id.btn_ind_sw1:
                        //Intent it = new Intent("myaction", Uri.parse("mysch://myqdu:8889/class5?qdu=test1&fac=comp"));
                        it.setAction("myaction");
                        it.setData(Uri.parse("mysch://myqdu:8889/class5?qdu=test1&fac=comp"));
                        startActivity(it);
                        break;
                    case R.id.btn_ind_sw2:
                        //Intent it = new Intent("myaction", Uri.parse("mysch://myqdu:8889/class1?qdu=test2&fac=software"));
                        it.setAction("myaction");
                        it.setData(Uri.parse("mysch://myqdu:8889/class1?qdu=test2&fac=software"));
                        startActivity(it);
                        break;
                }
            }
        };

        findViewById(R.id.btn_sw1).setOnClickListener(mylistner);
        findViewById(R.id.btn_ind_sw1).setOnClickListener(mylistner);
        findViewById(R.id.btn_ind_sw2).setOnClickListener(mylistner);
    }
}
